<template>
	<view>
		<view class="List">
			<view class="p-header" style="border-bottom: 1rpx solid #f4f4f4;">
				<view class="p-name">
					填写信息
				</view>
				<view class="p-status">
				</view>
			</view>
			<view class="p-content" v-if="st == 1">
				<view class="p-left">
					客户姓名
				</view>
				<view class="p-right">
					<input type="text" v-model="name" placeholder="请填写客户信息" />
				</view>
			</view>
			<view class="p-content" v-if="st == 1">
				<view class="p-left">
					客户电话
				</view>
				<view class="p-right">
					<input type="number" v-model="tel" maxlength="11" placeholder="请填写客户信息" />
				</view>
			</view>
			<view class="p-content" style="padding-bottom: 40rpx;" v-if="st == 1">
				<view class="p-left">
					客户地址
				</view>
				<view class="p-right">
					<input type="text" v-model="address" placeholder="请填写客户信息" />
				</view>
			</view>
		</view>
		<view class="sub-btn">
			<view class="submit" @tap="submit">
				添加客户
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				name: '',
				address: '',
				tel: '',
				st:0
			}
		},
		onShow() {
			this.st = uni.getStorageSync('st')
		},
		methods: {
			submit() {
				if (!this.name || !this.tel || !this.address) {
					uni.showToast({
						title: '请完善基本信息',
						icon: 'none'
					})
					return
				}
				uni.showLoading({
					title: '正在加载'
				})
				this.$http.Post('cper/kehuAdd', {
					name: this.name,
					address: this.address,
					tel: this.tel
				}, (result) => {
					uni.hideLoading()
					uni.showToast({
						title: '新增成功',
						icon: 'success'
					})
					setTimeout(res => {
						uni.navigateBack()
					}, 500)
				})
			}
		}
	}
</script>

<style>
	.List {
		margin: 60rpx auto 0 auto;
		width: 94%;
		border-radius: 16rpx;
		background-color: #fff;
	}

	.p-header {
		display: flex;
		align-items: center;
		justify-content: space-between;
		width: 94%;
		margin: 0 auto;
		height: 90rpx;
	}

	.p-name {
		font-weight: bold;
	}

	.p-status {
		border-radius: 8rpx;
		font-size: 28rpx;
		padding: 5rpx 12rpx;
		background-color: #f0f5fc;
		color: #669bf9;
	}

	.from {
		padding: 20rpx 0;
		width: 94%;
		border: 1rox solid black;
		margin: 20rpx auto;
		background-color: #fff;
		border-radius: 16rpx;
	}

	.p-content {
		width: 94%;
		margin: 20rpx auto;
		display: flex;
		align-items: center;
		color: #7a7a7a;
		font-size: 30rpx;
		height: 65rpx;
	}

	.p-left {
		width: 25%;
		height: 100%;
		display: flex;
		align-items: center;
		font-weight: bold;

	}

	.p-right {
		width: 75%;
		height: 100%;
		display: flex;
		align-items: center;
		justify-content: flex-end;
		text-align: right;
	}

	.sub-btn {
		position: fixed;
		bottom: 0;
		width: 100%;
		height: 120rpx;
		background-color: #fff;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.submit {
		width: 94%;
		height: 90rpx;
		border-radius: 16rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		color: #fff;
		font-size: 28rpx;
		background-color: #669bf9;
	}
</style>